/// @tags: Naive
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 1e5 + 2;

int a[maxn], c[maxn], tmp[maxn];

std::vector<int> col[maxn];

int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> c[i];
    col[c[i]].push_back(i);
  }
  for (int i = 1; i <= k; ++i) {
    if (!col[i].empty()) {
      for (size_t j = 0; j < col[i].size(); ++j) {
        tmp[j] = a[col[i][j]];
      }
      std::sort(tmp, tmp + col[i].size());
      for (size_t j = 0; j < col[i].size(); ++j) {
        a[col[i][j]] = tmp[j];
      }
    }
  }
  bool ans = true;
  for (int i = 2; i <= n; ++i) {
    if (a[i] < a[i - 1]) ans = false;
  }
  cout << (ans ? 'Y' : 'N');
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("B. Handling the Blocks.in", "r", stdin);
  freopen("B. Handling the Blocks.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
